package com.sskj.gcc.ui.activity;

import android.content.Context;
import android.content.Intent;
import android.support.v4.app.Fragment;
import android.view.View;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.flyco.tablayout.SegmentTabLayout;
import com.flyco.tablayout.listener.OnTabSelectListener;
import com.sskj.common.base.App;
import com.sskj.gcc.R;
import com.sskj.gcc.ui.fragment.OneSellFragment;
import com.sskj.gcc.ui.fragment.WithdrawFragment;
import com.sskj.gocoin.R2;
import com.sskj.gocoin.v.base.BaseActivity;
import com.sskj.lib.RConfig;

import java.util.ArrayList;

import butterknife.BindView;

/**
 * 充值
 *
 * @author Hey
 * Create at  2019/07/30 14:52:38
 */
@Route(path = RConfig.APP_WITHDRAW_HOME)
public class WithDrawHomeActivity extends BaseActivity<WithDrawHomePresenter> {

    @BindView(R2.id.back_tv)
    TextView backTv;
    @BindView(R2.id.tab_layout)
    SegmentTabLayout tabLayout;
    @BindView(R2.id.history_tv)
    TextView historyTv;


    ArrayList<Fragment> fragments=new ArrayList<>();
    @Override
    public WithDrawHomePresenter getPresenter() {
        return new WithDrawHomePresenter();
    }

    @Override
    public void initView() {
        backTv.setOnClickListener(v -> finish());
        String tiles[]=new String[]{App.INSTANCE.getString(R.string.app_withDrawHomeActivity1),App.INSTANCE.getString(R.string.app_withDrawHomeActivity2)};
        fragments.add(new WithdrawFragment());
        fragments.add(new OneSellFragment());
        tabLayout.setTabData(tiles, this, R.id.content, fragments);
        historyTv.setOnClickListener(v -> {
            SellRecordsActivity.start(this);
        });
        tabLayout.setCurrentTab(1);
    }

    @Override
    protected int getLayoutResId() {
        return R.layout.minefabi_activity_with_dra_whome;
    }

    @Override
    public void initData() {
        tabLayout.setOnTabSelectListener(new OnTabSelectListener() {
            @Override
            public void onTabSelect(int position) {
                if (position==1){
                    historyTv.setVisibility(View.VISIBLE);
                }else {
                    historyTv.setVisibility(View.GONE);
                }
            }

            @Override
            public void onTabReselect(int position) {

            }
        });
    }

    public static void start(Context context) {
        Intent intent = new Intent(context, WithDrawHomeActivity.class);
        context.startActivity(intent);
    }

}
